/*
 * @Descripttion: 需要测试Target类，但是它依赖于 Parent接口，而Parent 未实现的时候，可以使用mock
 * @Author: yubo
 * @Date: 2022-10-20 16:49:42
 * @LastEditTime: 2022-10-20 17:02:07
 */
#pragma once


#include <string>
using namespace std;

class Parent {
  public:
    virtual ~Parent() {}

    virtual int getNum() const = 0;
    virtual void setResult(int value) = 0;
    virtual void print(const string &str) = 0;
    virtual int calc(int a, double b) = 0;
};

class Target {
  public:
    Target(Parent *parent) :
        parent_(parent)
    { }

    int doThis()
    {
        int v = parent_->getNum();
        parent_->setResult(v);
        while (v-- > 0) {
            parent_->print(to_string(v));
        }
        return parent_->getNum();
    }

    int doThat()
    {
        return parent_->calc(1, 2.2);
    }

    string doSecond()
    {
      int calcRet = parent_->calc(3, 4.4);

      int num1 = parent_->getNum();
      int num2 = parent_->getNum();

      return to_string(calcRet - num1 - num2);
    }

  private:
    Parent *parent_;
};